package com.hcnow.common.model

import org.springframework.context.MessageSource
import org.springframework.stereotype.Component
import java.util.*

@Component
class MessageBuilder (var messageSource: MessageSource){

    fun createMessage(code: String): Message{
        return Message(code, parseMessage(code, null))
    }

    fun createMessage(code: String, params:Array<String>): Message {
        return Message(code, parseMessage(code, params))
    }

    fun parseMessage(code: String, params: Array<String>?): String {
        return messageSource.getMessage(code, params, Locale.CHINA)
    }
}